package best;

import java.util.Arrays;
import java.util.Scanner;

import javax.lang.model.element.Name;

public class PersonSortable {
	private String name;
	private int age;

	public PersonSortable(String name,int age)
	{
		this.name=name;
		this.age=age;
	}
	public String toString() {
		return "PersonSortable [name=" + name + ", age=" + age + "]";
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}
	public int CompareTo( PersonSortable o)
	{
		int x=this.getName().compareTo (o.getName());
		if (x!=0) 
		  return x;
		return this.getAge()-o.getAge();
	}

	public static void main(String[] args) {
		int n=5;
		Scanner s=new Scanner(System.in);
		PersonSortable[] person=new PersonSortable[5];
		person[0]=new PersonSortable("zhang", 15);
		person[1]=new PersonSortable("zhang" ,12);
		person[2]=new PersonSortable("ang", 14);
		person[3]=new PersonSortable("Wang", 17);
		person[4]=new PersonSortable("li",17);
		System.out.println(Arrays.toString(PersonSortable.class.getInterfaces()));
		for(PersonSortable person1:person)
		{
			System.out.println(person1);
		}
	}

}
